import java.sql.*;

import javax.swing.JOptionPane;

public class Conexion2 {
	
	private ResultSet rs;		
	private Connection conexionMYSQL;
	private Statement stmt = null;
	
	public Conexion2() {
		try {			
			conexionMYSQL = DriverManager.getConnection("jdbc:mysql://localhost:3306/dwes", "root", "a112358132134");	
			stmt = conexionMYSQL.createStatement();		
		}
		catch (SQLException sqlexception) {
			sqlexception.printStackTrace();
		}
	}
	
	public ResultSet getRs() {
		return rs;
	}
	
	public ResultSet hacerConsulta(String consulta) {
		try {
			this.rs = stmt.executeQuery(consulta);
		}
		catch (SQLException e) {			
			e.printStackTrace();
		}
		return this.rs;
	}
	
	public void hacerUpdate(String consulta) throws SQLException {				
		stmt.executeUpdate(consulta); 		
	}
	
	public void cerrarConexion() {
		try {
			conexionMYSQL.close();
		}
		catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public void cerrarStatement() {
		try {
			this.stmt.close();
		}
		catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public void cerrarRs() {
		try {
			this.rs.close();
		}
		catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
}
